package com.sun.asyncimporttask.exception;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;

/**
 * Excel导入专用异常
 */
@Getter
public class ExcelImportException extends RuntimeException {
    private final String errorCode;
    private final Integer rowIndex;
    private final Object rowData;

    public ExcelImportException(String message) {
        this(null, null, message);
    }

    public ExcelImportException(String errorCode, String message) {
        this(errorCode, null, message);
    }

    public ExcelImportException(String errorCode, Integer rowIndex, String message) {
        this(errorCode, rowIndex, null, message);
    }

    public ExcelImportException(String errorCode, Integer rowIndex, Object rowData, String message) {
        super(message);
        this.errorCode = errorCode;
        this.rowIndex = rowIndex;
        this.rowData = rowData;
    }

    public static ExcelImportException validationError(String field, String message) {
        return new ExcelImportException(
                "VALIDATION_ERROR",
                field + "校验失败: " + message
        );
    }

}